package net.wanho.shop.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import net.wanho.shop.dto.SMSLoginDTO;
import net.wanho.shop.service.SmsService;
import net.wanho.shop.vo.AjaxResult;
import net.wanho.shop.vo.LoginUserVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 这个类是：
 *
 * @author: MENG HU WANG
 * @date: 2025/1/4 16:05
 * @version: 1.0
 */


@Api(tags = "15.短信验证登录接口")
@RestController
@RequestMapping
@RequiredArgsConstructor
public class SmsController {

    private final SmsService smsService;


    @ApiOperation(value = "发送短信验证码")
    @GetMapping("smsCode")
    public AjaxResult sendSmsCode(String phone) {

        smsService.sendSmsCode(phone);
        return AjaxResult.success();

    }

    @ApiOperation(value = "短信验证码登录")
    @PostMapping("smsLogin")
    public AjaxResult smsLogin(@RequestBody SMSLoginDTO smsLoginDTO) {
        LoginUserVo loginUserVo = smsService.smsLogin(smsLoginDTO);
        return AjaxResult.success(loginUserVo);

    }

}
